import React, { useState } from "react";


function UseState(props) {
    // 声明一个新的叫做 “count” 的 state 变量
    const [count, setCount] = useState(0);
    const [user, setUser] = useState({
        name: "小红",
        age: 18
    })
    function setUserF(){
        setUser({
            name:"小明",
            age:count
        })
    }
    return (
        <div>
            <p>{props.title}</p>
            <p>count:{count}&nbsp;&nbsp;{user.name}{user.age}</p>
            <div><button onClick={() => setCount(count + 1)}>cout+1</button><button onClick={setUserF}>修改user</button></div>
        </div>
    )
}

export default UseState;